{extend name="../../admin/view/common/main"/}

{block name="body"}
<!-- 标题栏 -->
<div class="main-title">
    <h2>
        自动回复
    </h2>
</div>

<div class="with-padding">
    <div class="clearfix button-box tool-box row">
        <div class="col-xs-8 pd0">
            <a type="button" class="btn btn-info" href="{:url('editAutoReply')}" title="新增">
                新增
            </a>
            <button class="btn btn-success ajax-post" url="{:url('autoReplyStatus',['status'=>'1'])}" target-form="ids">
                启用
            </button>
            <button class="btn btn-warning ajax-post confirm" url="{:url('autoReplyStatus',['status'=>'0'])}" target-form="ids">
                禁用
            </button>
            <button class="btn btn-danger ajax-post confirm" url="{:url('autoReplyStatus',['status'=>'-1'])}" target-form="ids">
                删除
            </button>
        </div>

        <div class="search-form col-md-4">
            <div class="pull-right" style="display: inline-block;line-height: 32px;width:200px;margin-left:10px;">
                <div class="input-group">
                    <input type="text" name="keyword" class="search-input form-control" value="{:input('keyword')}"
                           placeholder="关键词">
                    <span class="input-group-btn">
                            <a class="btn btn-default" href="javascript:;" id="search" url="{:Url('autoReply')}">
                                <i class="icon-search"></i>
                            </a>
                        </span>
                </div>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table">
        <table class="table table-bordered table-striped table-hover muu-table">
            <thead>
            <tr>
                <th class="row-selected row-selected">
                    <input class="check-all" id="check-all" type="checkbox"/>
                    <label for="check-all"></label>
                </th>
                <th class="">{:lang("ID")}</th>
                <th>关键字</th>
                <th>回复内容</th>
                <th>备注</th>
                <th>类型</th>
                <th>状态</th>
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            {notempty name="list"}
            {volist name="list" id="vo"}
            <tr>
                <td>
                    <input class="ids" id="ids-{$vo.id}" type="checkbox" name="ids[]" value="{$vo.id}">
                    <label for="ids-{$vo.id}"></label>
                </td>
                <td>{$vo.id} </td>
                <td>{$vo.keyword}</td>
                <td>
                    {$vo.msg_type_str}消息
                </td>
                <td style="max-width: 300px" >
                    <p class="text-ellipsis text-nowrap">
                        {$vo.remark}
                    </p>
                </td>
                <td>{$vo.type_str}</td>
                <td>{$vo.status_str}</td>
                <td>
                    <a class="btn btn-sm btn-info" href="{:url('editAutoReply',['id'=>$vo['id']])}">
                        编辑
                    </a>
                    <button class="btn btn-sm btn-danger ajax-post confirm" url="{:url('autoReplyStatus',['ids'=>$vo['id'],'status'=>'-1'])}">
                        删除
                    </button>
                </td>
            </tr>
            {/volist}
            {else/}
            <td colspan="7" class="text-center"> aOh!空空如也~ </td>
            {/notempty}
            </tbody>
        </table>
    </div>
    <!-- 分页 -->
    <div class="page">
        {:htmlspecialchars_decode($page)}
    </div>
    <!-- /分页-->
</div>

{/block}
{block name="script"}
<script>
    $(function(){

        //设置url中参数值
        function changeURLArg(url,arg,arg_val){
            var pattern=arg+'=([^&]*)';
            var replaceText=arg+'='+arg_val;
            if(url.match(pattern)){
                var tmp='/('+ arg+'=)([^&]*)/gi';
                tmp=url.replace(eval(tmp),replaceText);
                return tmp;
            }else{
                if(url.match('[\?]')){
                    return url+'&'+replaceText;
                }else{
                    return url+'?'+replaceText;
                }
            }
        }

        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
    });
</script>
{/block}
